package org.xncj.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.entity.PageResult;
import org.entity.QueryPageBean;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import org.xncj.CheckItem;
import org.xncj.CheckItemSerivce;
import org.xncj.dao.CheckGroupDao;
import org.xncj.dao.CheckItemDao;


import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class CheckItemServiceImpl implements CheckItemSerivce {
    @Resource
    public CheckItemDao checkItemDao;
    @Resource
    public CheckGroupDao checkGroupDao;


    @Override
    public void addCheckItem(CheckItem checkItem) {
        checkItemDao.addCheckItem(checkItem);

    }

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        if ("null".equals(queryPageBean.getQueryString())){
            queryPageBean.setQueryString("null");
        }
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<CheckItem> page = checkItemDao.findPage(queryPageBean.getQueryString());
        PageResult pageResult = new PageResult(page.getTotal(),page.getResult());
        return pageResult;
    }

    @Override
    public void deleteById(Integer checkItemId) {
        checkItemDao.deleteCheckItem(checkItemId);

    }

    @Override
    public void updateCheckItem(CheckItem checkItem) {
        checkItemDao.updateCheckItem(checkItem);
    }

    @Override
    public List<CheckItem> findAll() {
        return checkItemDao.findAll();
    }



}
